export default {
  install(Vue) {
    // 定义全局的过滤器
    Vue.filter('mySlice', function(value) {
      return value.slice(0, 4)
    });

    // 定义全局的指令
    Vue.directive('focus-bind', {
      bind(element, binding) {
        console.log('focus-bind', binding)
        element.value = binding.value;
      },
      inserted(element, binding) {
        console.log('focus-bind', binding)
        element.value = binding.value;
        element.focus()
      },
      update(element, binding) {
        console.log('focus-bind', binding)
        element.value = binding.value;
        // element.focus()
      },
    })

    //定义混入
    Vue.mixin({
      data() {
        return {
          x: 100,
          y: 100,
        }
      }
    })

    // 原型增加
    Vue.prototype.hello = () => alert('hello');
  }
}